﻿using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace CSharpConsoleTestSolution.Models {
    
    //copy from https://learn.microsoft.com/zh-cn/ef/core/
    public class AdventureWords2014Entities : DbContext {
        
        public DbSet<Blog> Blogs { get; set; }
        public DbSet<Post> Posts { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
            //TODO: 没有这个方法, 不是最新版的原因??
            // optionsBuilder.UseSqlServer(
            //     @"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;ConnectRetryCount=0"
            //     );
        }
    }

    public class Blog {
        public int BlogId { get; set; }
        public string Url { get; set; }
        public int Rating { get; set; }
        public List<Post> Posts { get; set; }
    }

    public class Post {
        public int PostId { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }

        public int BlogId { get; set; }
        public Blog Blog { get; set; }
    }
}